perm filename TMP2[MF,ALS] blob sn#757778 filedate 1984-06-21 generic text, type C, neo UTF8
COMMENT ⊗   VALID 00002 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002
C00005 ENDMK
C⊗;

function do_char:boolean;
label 1,2,3,4,9997,9998,9999;
var o:eight_bits; {operation code of the current command}
@!p,@!q:integer; {parameters of the current command}
i,j: integer; {used to index in |select byte type|}
b: eight_bits; {holding byte for |PXL| bits}
begin {we've already scanned the |boc|}
do_char←true;
while true do @<Translate the next command in the \.{GF} file;
		|goto 9999| if it was |eoc|;
		|goto 9998| if premature termination is needed@>;
9998: print_ln('!'); do_char←false; goto 9997;
9999:
@<Remove white rows and columns@>;
@<Encode the glyph@>;
9997: end;

@ This is the main command loop.

@d error(#)==begin print(a:1,': ! ',#); print_nl; end

@<Translate the next command...@>=
begin a←cur_loc;
o←get_byte; p←first_par(o);
if eof(gf_file) then bad_gf('the file ended prematurely');
@.the file ended prematurely@>
@<Translate command |o|@>;
end

@ The multiway switch in |first_par|, above, was organized by the length
of each command; the one in |do_char| is organized by the semantics.

@<Translate command...@>=
if o≤paint1+3 then @<Translate a |paint| command@>
else if (new_row≤o) and (o≤right_z_83) then
	@<Translate a |new_row|, |right| or |left| command@>
else case o of
	three_cases(skip1): @<Translate a |skip| command@>;
	@t\4@>@<Cases for commands |nop|, |pre|, |post|, |post_post|, |boc|,
		and |eoc|@>@;
	four_cases(xxx1): @<Translate an |xxx| command@>;
	yyy: @<Translate a |yyy| command@>;
	othercases error('undefined command ',o:1,'!')
@.undefined command@>
	endcases